package com.itheima.config;

import com.itheima.interceptor.Interceptors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration //声明当前类是一个可配置类
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private Interceptors interceptors;

    //添加拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册拦截器 排除登录页面
        registry.addInterceptor(interceptors).addPathPatterns("/**").excludePathPatterns("/login");
    }

}
